package com.kevin.model;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

import lombok.Data;

import org.nutz.dao.entity.annotation.Column;
import org.nutz.dao.entity.annotation.Default;
import org.nutz.dao.entity.annotation.Id;
import org.nutz.dao.entity.annotation.Next;
import org.nutz.dao.entity.annotation.One;
import org.nutz.dao.entity.annotation.Table;

/**
 * 日历类
 * 
 * @author Administrator
 * 
 */
@Table("user_calender")
public @Data class UserCalender implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 879047797257454110L;
	/* * 数据库ID */
	@Id
	@Column("id")
	private int ucid;
	/* * 标题 */
	@Column
	private String title;	
	/* * 开始时间 */
	@Column("starttime")
	private Date start;
	/* * 结束时间 */
	@Column("endtime")
	private Date end;
	/* * 描述 */
	@Column
	private String description;
	/* * url */
	@Column
	private String url;
	/* * 日历事件所有人 */
	@Column
	private int userid;
	
	@One(target = UserInfo.class, field = "userid")
	private UserInfo addUser;
	
	/* * 日历事件id用于重复事件 */
	@Column("eventid")
	private int id;
	
	@Default(value="${start.hours}")
	private boolean allDay;

	public boolean isAllDay() {
		Calendar cal = Calendar.getInstance();
		cal.setTime(start);		
		if(cal.get(Calendar.HOUR_OF_DAY) == 0)
			allDay = true;
		return allDay;
	}

	public void setAllDay(boolean allDay) {
		this.allDay = allDay;
	}

	

	
	
	
	
}
